package com.zide.ams.controller;

import java.util.List;

import com.zide.ams.domain.vo.result.AmsCategoryResultVO;
import com.zide.ams.domain.vo.save.AmsCategorySaveVO;
import com.zide.ams.domain.vo.search.AmsCategorySearchVO;
import com.zide.ams.service.IAmsCategoryService;
import com.zide.common.core.vo.CommonParamIdVO;
import jakarta.servlet.http.HttpServletResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zide.common.core.domain.PageResult;
import com.zide.common.core.domain.CommonResult;
import static com.zide.common.core.domain.CommonResult.getResult;
import static com.zide.common.core.domain.CommonResult.success;

/**
 * 文章分类Controller
 * 
 * @author zide
 * @date 2024-04-29
 */
@Tag(name = "文章分类")
@RestController
@RequestMapping("/ams/category")
public class AmsCategoryController {
    @Autowired
    private IAmsCategoryService amsCategoryService;


    @Operation(summary = "查询文章分类列表")
    @GetMapping("/list")
    public CommonResult list(AmsCategorySearchVO searchVO) {

        List<AmsCategoryResultVO> list = amsCategoryService.searchAmsCategoryList(searchVO);
        return success(list);
    }


    @Operation(summary = "获取文章分类详细信息")
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id) {
        return success(amsCategoryService.selectAmsCategoryById(id));
    }

    @Operation(summary = "新增文章分类")
    @PostMapping
    public CommonResult add(@RequestBody AmsCategorySaveVO saveVO) {
        return getResult(amsCategoryService.saveAmsCategory(saveVO));
    }

    @Operation(summary = "修改文章分类")
    @PutMapping
    public CommonResult edit(@RequestBody AmsCategorySaveVO saveVO){
        return getResult(amsCategoryService.updateAmsCategory(saveVO));
    }

    @Operation(summary = "修改分类状态")
    @PutMapping("status")
    public CommonResult updateStatus(@RequestBody AmsCategorySaveVO saveVO){
        return getResult(amsCategoryService.updateStatus(saveVO));
    }

    @Operation(summary = "删除文章分类")
	@DeleteMapping
    public CommonResult remove(@RequestBody CommonParamIdVO idVO){
        return getResult(amsCategoryService.removeAmsCategoryByIds(idVO));
    }
}
